package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.YuMain;
import com.ruoyi.system.service.IYuMainService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 鱼主Controller
 * 
 * @author ruoyi
 * @date 2025-08-29
 */
@RestController
@RequestMapping("/system/main")
public class YuMainController extends BaseController
{
    @Autowired
    private IYuMainService yuMainService;

    /**
     * 查询鱼主列表
     */
    @PreAuthorize("@ss.hasPermi('system:main:list')")
    @GetMapping("/list")
    public TableDataInfo list(YuMain yuMain)
    {
        startPage();
        List<YuMain> list = yuMainService.selectYuMainList(yuMain);
        return getDataTable(list);
    }

    /**
     * 导出鱼主列表
     */
    @PreAuthorize("@ss.hasPermi('system:main:export')")
    @Log(title = "鱼主", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YuMain yuMain)
    {
        List<YuMain> list = yuMainService.selectYuMainList(yuMain);
        ExcelUtil<YuMain> util = new ExcelUtil<YuMain>(YuMain.class);
        util.exportExcel(response, list, "鱼主数据");
    }

    /**
     * 获取鱼主详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:main:query')")
    @GetMapping(value = "/{yuId}")
    public AjaxResult getInfo(@PathVariable("yuId") Long yuId)
    {
        return success(yuMainService.selectYuMainByYuId(yuId));
    }

    /**
     * 新增鱼主
     */
    @PreAuthorize("@ss.hasPermi('system:main:add')")
    @Log(title = "鱼主", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YuMain yuMain)
    {
        return toAjax(yuMainService.insertYuMain(yuMain));
    }

    /**
     * 修改鱼主
     */
    @PreAuthorize("@ss.hasPermi('system:main:edit')")
    @Log(title = "鱼主", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YuMain yuMain)
    {
        return toAjax(yuMainService.updateYuMain(yuMain));
    }

    /**
     * 删除鱼主
     */
    @PreAuthorize("@ss.hasPermi('system:main:remove')")
    @Log(title = "鱼主", businessType = BusinessType.DELETE)
	@DeleteMapping("/{yuIds}")
    public AjaxResult remove(@PathVariable Long[] yuIds)
    {
        return toAjax(yuMainService.deleteYuMainByYuIds(yuIds));
    }
}
